#pragma once

#include <windows.h>
#include <vector>

namespace MCCommon
{
class IRunnable;
class MCThread
{
public:
    /*
     *	Constructor.
     */        
    MCThread();

    /*
     *	Destructor.
     */
    virtual ~MCThread();

    /*
     *	Start the thread.
     */
    void Start();

    /*
     *	Stop the thread.
     */
    void Stop();

    /*
     *	Submit a runnable object.
     */
    void Submit
    (
        IRunnable* pRunableOject
    );

    /*
     *	Join a thread.
     */
    void Join
    (
    );

    /**
     * The task function of this thread.
     * 
     */
    virtual void Run();

    /**
     * Cancel the runnable task.
     * 
     */
    virtual void Cancel();
    
private:

    // The runnable task list.
    std::vector< IRunnable* > fvpTasks;

    // The handle of this thread.
    HANDLE fThreadHandle;    
};

} // end of namespace MCCommon